<link href="__ADMIN__/css/juncms.min2.css?v=1" rel="stylesheet" type="text/css" />  



<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					<em>
						日志编码管理
					</em>
					...
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">


                                <div class="org-left-col tray-cell j_depa" style="float:left;margin-right: 10px">
                                    <div id="mCSB_32_container" class="mCSB_container mCS_y_hidden mCS_no_scrollbar_y" style="padding: 10px;">
                                            <div class="user-sortbar table-tray"></div>
                                            <input type="hidden" id="upd_id">
                                            <div class="control-group">
                                                <label class="control-label">
                                                    日志类型：
                                                </label>
                                                <div class="controls js_formcategory">
                                                    <select class="js_company_select form-control" id="pid">
                                                        {foreach name="Log_Type" item="v" key="k" }
                                                            <option value="{$k}">{$v}</option>
                                                        {/foreach}
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">
                                                    解析名：
                                                </label>
                                                <div class="controls">
                                                    <input type="text" class="form-control w-350" id="name" placeholder="例如：修改日志">
                                                </div>
                                            </div>
                                            
                                            <div class="control-group ">
                                                <label class="control-label"> </label>
                                                <div class="controls">
                                                    {if condition="$adminController->vif('logtype','add')"}<button class="btn btn-sm btn-primary add_prevstep" style="display: inline-block;">确认创建</button>{/if}
                                                    {if condition="$adminController->vif('logtype','upd')"}<button class="btn btn-sm btn-success upd_prevstep" style="display: none">确认修改</button>{/if}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>


								<div class="fixed-table-toolbar" style="width:-webkit-calc(100% - 310px); width:-moz-calc(100% - 310px); width:calc(100% - 310px);float: left;">
									<div class="bs-bars pull-left">
										<div id="toolbar" class="toolbar">
											<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
												<i class="fa fa-refresh"></i>
                                            </a>
                                            {if condition="$adminController->vif('logtype','add')"}
											<a href="javascript:add('{:url('index')}');" class="btn btn-success btn-add" title="添加">
												<i class="fa fa-plus"></i> 添加
                                            </a>
                                            {/if}
										</div>
									</div>
									<div class="columns columns-right btn-group pull-right">
										
										<div class="keep-open btn-group" title="列">
											<button type="button" aria-label="columns" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
												<i class="glyphicon glyphicon-th icon-th"></i>
												<span class="caret"></span>
											</button>
											<ul class="dropdown-menu" id="table_menu">
												
											</ul>
										</div>
                                        
									</div>
								</div>
								<div class="fixed-table-container" style="width:-webkit-calc(100% - 310px); width:-moz-calc(100% - 310px); width:calc(100% - 310px);float: left;">
									<div class="fixed-table-body">
										<table id="table" class="table table-striped table-bordered table-hover"
										data-operate-edit="1" data-operate-del="1" width="100%">
											<thead>
												<tr>
                                                    <th data-status="1"><div class="th-inner">ID</div></th>
                                                    <th data-status="1"><div class="th-inner">类型</div></th>
                                                    <th data-status="1"><div class="th-inner">编码名称</div></th>
                                                    <th data-status="1" width="100px"><div class="th-inner">操作</div></th>
												</tr>
											</thead>
                                            
											<tbody>
                                                {volist name="list" id="v"}
                                                <tr class="del-{$v.lt_id}">
                                                    <td align="center">{$v.lt_id}</td>
                                                    <td align="center">
                                                        {foreach name="Log_Type" item="val" key="key" }
                                                            {eq name="v.lt_mode" value="$key"}{$val}{/eq}
                                                        {/foreach}
                                                    </td>
                                                    <td align="center"><a>{$v.lt_name}</a></td>
                                                    <td align="center">
                                                        {if condition="$adminController->vif('logtype','upd')"}
                                                        <button data-id="{$v.lt_id}" data-mode="{$v.lt_mode}" data-name="{$v.lt_name}" class="btn btn-xs btn-success btn-editone upd_success" title="编辑">
                                                            <i class="fa fa-pencil"></i>
                                                        </button>
                                                        {/if}
                                                        {if condition="$adminController->vif('logtype','del')"}
                                                        <button data-id="{$v.lt_id}" class="btn btn-xs btn-danger btn-delone del_success" title="删除">
                                                            <i class="fa fa-trash"></i>
                                                        </button>
                                                        {/if}
                                                    </td>
                                                </tr>
                                                {/volist}
                                                
											</tbody>
										</table>
                                    </div>
                                    <div class="fixed-table-pagination" style="display: block;">
										<div class="pull-left pagination-detail">
											{$page}
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

								
<script>
layui.use(['form'], function(){
  var form = layui.form;
});

// 监听添加
$(".add_prevstep").on('click', function(){
	var pid  = $('#pid').val();
	var name = $('#name').val();
	var data = {'pid':pid, 'name':name};

	if (name == '') {
		$.thinkmimi({Content : '解析名称不能为空！', Type:2, Align:'right', OutTime:2000});return false;
	}

	$.ajax({
		type: 'post',
		data: data,
		url: "{:url('logtype/add')}",
		success: function(data) {
			var array = eval('(' + data+ ')');
			if (array['code'] == '01') {
                $.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				setTimeout(function(){window.location.href = "{:url('logtype/index')}";},800); 
			}
		}
	});
});

// 点击修改获得参数
$(".upd_success").on('click', function(){
	var id   = $(this).attr('data-id');
    var mode = $(this).attr('data-mode');
    var name = $(this).attr('data-name');

    $('#upd_id').val(id);
    $('#name').val(name);
    $("#pid").val(mode);
	$('.upd_prevstep').css('display','inline-block');
    $('.add_prevstep').css('display','none');
});

// 监听修改提交
$(".upd_prevstep").on('click', function(){
    var upd_id = $('#upd_id').val();
	var pid    = $('#pid').val();
	var name   = $('#name').val();
	var data   = {'upd_id':upd_id, 'pid':pid, 'name':name};

	if (name == '') {
		$.thinkmimi({Content : '解析名称不能为空！', Type:2, Align:'right', OutTime:2000});return false;
	}

	$.ajax({
		type: 'post',
		data: data,
		url: "{:url('logtype/upd')}",
		success: function(data) {
			var array = eval('(' + data+ ')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				setTimeout(function(){window.location.reload();},1500); 
			}
		}
	});
});

// 删除
$(".del_success").on('click', function(){
    if (confirm('确认删除吗')) {
        var id   = $(this).attr('data-id');
        var data = {'id':id};

        $.ajax({
            type: 'post',
            data:data,
            url: "{:url('del')}",
            success: function(data) {
                var array = eval('('+data+')');
				if (array['code'] == '01') {
					$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
				} else {
					$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
					$('.del-'+id).remove();
				}
            }
        });
    }
});
</script>